<%@ page import="com.conversationboard.model.*" %>
<%@ page import="com.conversationboard.view.*" %>
<%@ page import="com.conversationboard.config.*" %>
<%@ page import="java.security.*" %>

<%@page pageEncoding="UTF-8"%>
<%@page contentType="text/html;charset=UTF-8"%>

<% 
	// Pick up the Board ID from the HTTP GET parameter
    String boardId = (String) request.getParameter("boardid");
	int boardIdNumber = Integer.parseInt(boardId);
	Board board = Boards.getBoard(boardIdNumber);
	Principal principal = request.getUserPrincipal();
	User user = User.get(principal);
	boolean loggedIn = (principal != null);
	
	String servletName = "NewQuestionControllerServlet";

	if (!board.isRequireRegistration()) {
		servletName = "unregistered/NewQuestionControllerServlet";
	}
	
%>

<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
		<title><%=board.getName()%>: New Poll</title>
		<link rel="stylesheet" type="text/css" href="<%=Configuration.getInstance().getRoot()%>/Stylesheets/<%=StyleSheets.getStyleSheetFileName(request.getCookies())%>"/>
		<script src="${contextPath}/Javascript/style.js" type="text/javascript"></script>
	</head>

	<body>

		<%= MenuDisplay.display(board, false, principal) %>

		<div class="headingblock">
			<h1><%=board.getName()%>: New Poll</h1>
		</div>
	
		<div class="mainblock">
		
			<% if ((board.isPostable(user) && loggedIn) || (!board.isRequireRegistration())) { %>
				<form class="formsection" action="<%=Configuration.getInstance().getRoot()%>/<%= servletName %>" method="post">
					
					<h2>Create a New Poll</h2>
	
					Note that formatting will only work within the question text.<br /><br />
	
				 	<input name="boardId" value="<%=boardId%>" type="hidden" />
				 	<input name="poll" value="true" type="hidden" />
				 	<input name="sKey" value="<%= request.getSession().getId()%>" type="hidden" />
	
					<!-- Basic Poll Title and Text -->
				 	
				 	<label for="questionTitle"><strong><%=board.getName()%></strong> Poll Title:</label><br /><br />
				 	<input class="textbox" name="questionTitle" type="text" size=100 /><br /><br />
				 	<label for="closingDate"><strong><%=board.getName()%></strong> Poll Closing Date (YYYY-MM-DD):</label><br /><br />
				 	<input class="textbox" name="closingDate" type="text" size=100 /><br /><br />
				 	<label for="questionText"><strong><%=board.getName()%></strong> Poll Text:</label><br /><br />
				 	<textarea class="textbox" name="questionText" rows=4 cols=80></textarea><br /><br />
	
					<!-- Create Single Textbox to Enter Poll Items. Delimit by new line. -->
	
				 	<label for="pollItems"><strong><%=board.getName()%></strong> Poll Options: Enter all options, delimited by new lines</label><br /><br />
				 	<textarea class="textbox" name="pollItems" rows=10 cols=80></textarea><br /><br />

					<% if (!board.isRequireRegistration()) { %>
					 	<label for="Display Name"><strong>Name</strong></label><br />
					 	<input name="displayname" class="smalltextbox" size=50 /><br /><br />
					<% } %>
	
				 	<input type="submit" value="Create Poll" />
				</form>
	
				<div class="formattingLink">
					<p><a name="fh" href="#fh" onClick="setStyleByClass('div','formatting','display', 'inline'); setStyleByClass('div','formattingLink','display', 'none');">Show Formatting Help</a></p>
				</div>
						
				<div class="formatting">
					<h3>Formatting help</h3>
					
					<table>
						<tr>
							<td>For <strong>strong text</strong>, use:</td>
							<td><code>[b]<em class='inlinetext'>your text</em>[/b]</code></td>
						</tr>
						<tr>
							<td>For <em>emphasised text</em>, use:</td>
							<td><code>[i]<em class='inlinetext'>your text</em>[/i]</code></td>
						</tr>
						<tr>
							<td>For <strike>strikethrough text</strike>, use:</td>
							<td><code>[s]<em class='inlinetext'>your text</em>[/s]</code></td>
						</tr>
	                              		<tr>
							<td>For <u>underlined text</u>, use:</td>
							<td><code>[u]<em class='inlinetext'>your text</em>[/u]</code></td>
						</tr>	
						<tr>
							<td>For block quotes, use:</td>
							<td><code>[q]<em class='inlinetext'>your text</em>[/q]</code></td>
						</tr>
						<tr>
							<td>For literal, non-proportional text, use:</td>
							<td><code>[code]<em class='inlinetext'>your text</em>[/code]</code></td>
						</tr>
						<tr>
							<td>For images, use:</td>
							<td><code>[img]<em class='inlinetext'>http://www.website.com/image.jpeg</em>[/img]</code></td>
						</tr>
	                    <tr>
	                        <td>For hyperlinks, use:</td>
	                        <td><code>[url=<em class='inlinetext'>http://www.mywebsite.com/mylink.html</em>]<em class='inlinetext'>My Link Title</em>[/url]</code> or<br />
	                        <code>[url]<em class='inlinetext'>http://www.mywebsite.com/mylink.html</em>[/url]</code></td>
	                    </tr>
						<tr>
							<td>For YouTube embedded videos:</td>
							<td>Paste in the URL of the YouTube web page containing the video you wish to embed</td>
						</tr>
						<tr>
							<td>For bulleted lists:</td>
							<td>Place a -* at the start of each bullet point. The bulleted list will continue until you start a line without a -*</td>
						</tr>
					</table>
				</div>
	
				 	
			<% } else { %>

				<p>You must be logged in to post on public boards. Please <a href="<%=Configuration.getInstance().getRoot()%>/LoginControllerServlet">Login</a> or
				   <a href="Pages/register.jsp">Register</a> if you are not already registered.</p>
			
			<% } %>
			
		</div>

		<!--<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>-->
		<!--<script type="text/javascript">_uacct = "UA-1148679-1";urchinTracker();</script>--> 
		
	</body>
	
</html>
